package com.kotlin.tsw.baselibrary.ui.fragment

import android.os.Bundle
import com.kotlin.tsw.baselibrary.common.BaseApplication
import com.kotlin.tsw.baselibrary.injection.component.ActivityComponent
import com.kotlin.tsw.baselibrary.injection.component.DaggerActivityComponent
import com.kotlin.tsw.baselibrary.injection.module.ActivityModule
import com.kotlin.tsw.baselibrary.injection.module.LifecycleProviderModule
import com.kotlin.tsw.baselibrary.persenter.BasePresenter
import com.kotlin.tsw.baselibrary.persenter.view.BaseView
import javax.inject.Inject

open abstract class BaseMVPFragment<T : BasePresenter<*>> : BaseFragment(), BaseView {
    override fun showLoading() {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }

    override fun hideLoading() {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }

    override fun onErorr(text:String) {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }

    @Inject
    lateinit var mPresenter: T
    lateinit var activityComponent: ActivityComponent
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        initActivityInjection()
        injectComponent()
    }
    abstract  fun injectComponent()
    private fun initActivityInjection() {
        activityComponent = DaggerActivityComponent.builder()
                .appComponent((activity?.application as BaseApplication).appComponent)
                .activityModule(ActivityModule(this.activity!!))
                .lifecycleProviderModule(LifecycleProviderModule(this))
                .build()
    }
}